import { Constant } from "../../Constant";
import { Main } from "../../Main";
import StateBase from "../StateBase";

export default class SecondRecruit1PrepareState extends StateBase {
    begin(preState: number): void {
        super.begin(preState);
       // console.log('SecondRecruit1PrepareState state--begin');
        const main = this.getUserData() as Main;

        main.frontBg.playAnimation(Constant.FrontBgAni.Close, 0.2, () => {
            main.enterRolesRoles[1].setHide();
            main.scheduleOnce(() => {
                main.frontBg.playAnimation(Constant.FrontBgAni.Appear, 0.2, () => {
                    main.secRoundRoles.forEach(e => {
                        e.setActive(true);
                    });

                    main.roundOptions[2].active = true;
                    main.lightAnimation.setColor([3, 1, 3]);
                    main.secRoundRoles[0].setSelect();
                    main.secRoundRoles[0].setGray();

                    main.roundTips[2].showStart(true);
                    main.secRoundRoles?.forEach((note, index) => {
                        note.startGlow(() => {
                            main.lightAnimation.showLight(index);
                            if (index == 0) {
                                main.lightAnimation.setActive(0, false);
                            }
                        }, this)
                    })
                }, this);
            }, 1)
        }, this);
    }
}